package com.letian.im.service.impl;

import java.util.List;

import com.letian.common.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.letian.im.mapper.ImChatMsgMapper;
import com.letian.im.domain.ImChatMsg;
import com.letian.im.service.IImChatMsgService;

/**
 * 聊天信息Service业务层处理
 *
 * @author bmz
 * @date 2023-08-13
 */
@Service
public class ImChatMsgServiceImpl implements IImChatMsgService {
    @Autowired
    private ImChatMsgMapper imChatMsgMapper;

    /**
     * 查询聊天信息
     *
     * @param id 聊天信息主键
     * @return 聊天信息
     */
    @Override
    public ImChatMsg selectImChatMsgById(Long id) {
        return imChatMsgMapper.selectImChatMsgById(id);
    }

    /**
     * 查询聊天信息列表
     *
     * @param imChatMsg 聊天信息
     * @return 聊天信息
     */
    @Override
    public List<ImChatMsg> selectImChatMsgList(ImChatMsg imChatMsg) {
        return imChatMsgMapper.selectImChatMsgList(imChatMsg);
    }

    /**
     * 新增聊天信息
     *
     * @param imChatMsg 聊天信息
     * @return 结果
     */
    @Override
    public int insertImChatMsg(ImChatMsg imChatMsg) {
        imChatMsg.setCreateTime(DateUtils.getNowDate());
        return imChatMsgMapper.insertImChatMsg(imChatMsg);
    }

    /**
     * 修改聊天信息
     *
     * @param imChatMsg 聊天信息
     * @return 结果
     */
    @Override
    public int updateImChatMsg(ImChatMsg imChatMsg) {
        return imChatMsgMapper.updateImChatMsg(imChatMsg);
    }

    /**
     * 批量删除聊天信息
     *
     * @param ids 需要删除的聊天信息主键
     * @return 结果
     */
    @Override
    public int deleteImChatMsgByIds(Long[] ids) {
        return imChatMsgMapper.deleteImChatMsgByIds(ids);
    }

    /**
     * 删除聊天信息信息
     *
     * @param id 聊天信息主键
     * @return 结果
     */
    @Override
    public int deleteImChatMsgById(Long id) {
        return imChatMsgMapper.deleteImChatMsgById(id);
    }

    @Override
    public int updateMsgSigned(List<Long> ids) {
        Long[] idArr = new Long[ids.size()];
        for (int i = 0; i < ids.size(); i++) {
            idArr[i] = ids.get(i);
        }
        return imChatMsgMapper.batchUpdateMsgSigned(idArr);
    }
}
